﻿using SshNet.Security.Cryptography;
using StudyStationWEBAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace StudyStationWEBAPI.Model
{
    public class Encription
    {
        // 这是一个外观者，封装了token以及MD5算法
        /// <summary> 将密码使用MD5算法加密
        /// </summary>
        /// <param name="pwd">密码</param>
        public string GetMD5Hash(string pwd)
        {
            string password = MyMD5.GetMd5Hash(pwd);
            return password;
        }

        /// <summary> 生成token
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public string GetToekn(string userName)
        {
            TokenInfo tokenInfo = new TokenInfo(userName);
            string token = TokenHelper.GenToken(tokenInfo);
            return token;
        }

    }
}
